<?php
    session_start();
    include('top.php');
    $i = 1;
?>
    <style>
        #ui_div_border {
            visibility: hidden;
        }
    </style>
    <div class="home-body">
        <?php include('info.php'); ?>

            <div class="home-container-body">
                <div class="home-side-by-side-start" style="width: 300px;">
                    <form id="uploadForm" enctype="multipart/form-data">
                        <table width="100%">
                            <tr>
                                <td class="select-td">
                                    <input type="file" id="imageUpload" name="imageUpload" class="index_input">
                                </td>
                            </tr>
                            <tr>
                                <td class="select-td">
                                    <label><input type="radio" name="type" value="photo">照片</label>
                                    <label><input type="radio" name="type" value="cardz">身份证正面</label>
                                    <label><input type="radio" name="type" value="cardf">身份证反面</label>
                                    <label><input type="radio" name="type" value="sqb">考生申请表</label>
                                    <label><input type="radio" name="type" value="cns">考生承诺书</label>
                                    <label><input type="radio" name="type" value="cjd">本科阶段成绩单</label>
                                    <label><input type="radio" name="type" value="bgd">学历验证报告单</label>
                                    <label><input type="radio" name="type" value="xlzsphoto">学历证书</label>
                                    <label><input type="radio" name="type" value="xwzsphoto">学位证书</label>
                                </td>
                            </tr>
                            <tr>
                                <td class="select-td">
                                    <button type="button" id="uploadButton" class="my-home-submit">上传</button>
                                </td>
                            </tr>
                        </table>
                    </form>
                    <table width="100%">
                        <tr>
                            <th class="select-th">序号</th>
                            <th class="select-th">文件名</th>
                            <th class="select-th">文件类型</th>
                            <th class="select-th">上传时间</th>
                            <th class="select-th">操作</th>
                        </tr>
                        <?php
                            $upload = "select * from upload where uid = $uid";
                            $upload_result = $link->query($upload);
                            while ($upload_row = mysqli_fetch_array($upload_result)) {
                        ?>
                        <tr>
                            <td class="select-td"><?php echo $i++; ?></td>
                            <td class="select-td"><a href="<?php echo "/File_uploads/" . $uid . $upload_row['files']; ?>"><?php echo "/File_uploads/" . $uid . $upload_row['files']; ?></a></td>
                            <td class="select-td">
                                <?php
                                    $param = $upload_row['type'];
                                    switch ($param) {
                                        case 'photo':
                                            echo '照片';
                                            break;
                                        case 'cardz':
                                            echo '身份证正面';
                                            break;
                                        case 'cardf':
                                            echo '身份证反面';
                                            break;
                                        case 'sqb':
                                            echo '申请表';
                                            break;
                                        case 'cns':
                                            echo '承诺书';
                                            break;
                                        case 'cjd':
                                            echo '本科阶段成绩单';
                                            break;
                                        case 'bgd':
                                            echo '学历验证报告单';
                                            break;
                                        case 'xlzsphoto':
                                            echo '学历证书';
                                            break;
                                        case 'xwzsphoto':
                                            echo '学位证书';
                                            break;
                                        default:
                                            echo '无效的参数';
                                    }
                                ?>
                            </td>
                            <td class="select-td"><?php echo date("Y-m-d H:i:s",$upload_row['time']) ?></td>
                            <td class="select-td">
                                <a href="javascript:;" onclick="if(confirm('您确定要删除吗？')){ actionControl('delfiles','<?php echo $upload_row['id']; ?>', '<?php echo $upload_row['files'] = str_replace('/' , '',  $upload_row['files']); ?>') }">删除</a>
                            </td>
                        </tr>
                        <?php } ?>
                    </table>
                    <p style="margin-top: 12px; text-indent: 2em;">请考生仔细阅读上传规则</p>
                    <hr noshade />
                    <p style="margin-top: 12px; text-indent: 2em;">资料上传功能可用于上传照片、身份证正面与反面、学历证书图片、学历验证报告单、学位证书图片，请考生将扫描（拍照）的文件名称改为英文，上传完成后即能在上传资料相应位置显示已上传的内容，入学修改请删除原先的内容再次上传即可，请勿上传大于2MB且非JPG、PNG、PDF类型的图片，图片上传的二级目录为考生的ID号。</p>
                    <p style="text-indent: 2em;">正常情况下，您的ID为
                        <?php echo $uid; ?>，因此在
                            <?php echo $uid; ?>文件夹下有您的照片、身份证正面与反面、考生申请表、考生承诺书、学历验证报告单、学历证书（毕业证书）、学位证书共8张图片（如果需要本科阶段成绩单则为9张），图片上传功能不限上传次数，如果您需要修改某张照片可删除原先的资料。</p>
                </div>
            </div>
    </div>
    <div class="ui_div_border" id="ui_div_border">
        <table class="ui_border ui_state_visible ui_state_focus ui_state_lock" id="alert">
            <tbody>
                <tr>
                    <td class="ui_lt"></td>
                    <td class="ui_t"></td>
                    <td class="ui_rt"></td>
                </tr>
                <tr>
                    <td class="ui_l"></td>
                    <td class="ui_c">
                        <div class="ui_inner">
                            <table class="ui_dialog">
                                <tbody>
                                    <tr>
                                        <td colspan="2">
                                            <div class="ui_title_bar">
                                                <div class="ui_title" unselectable="on" style="cursor: move;">警告</div>
                                                <div class="ui_title_buttons"><a class="ui_close" href="javascript:void(0);" title="关闭(esc键)" style="display: inline-block;">×</a></div>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="ui_icon" style=""><img src="/static/img/alert.gif" class="ui_icon_bg"></td>
                                        <td class="ui_main" style="width: 200px; height: auto;">
                                            <div id="imageUrl" class="popup"></div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <div class="ui_buttons" style="">
                                                <input type="button" value="确定" class="ui_state_highlight" onclick="location.reload();">
                                            </div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </td>
                    <td class="ui_r"></td>
                </tr>
                <tr>
                    <td class="ui_lb"></td>
                    <td class="ui_b"></td>
                    <td class="ui_rb" style="cursor: auto;"></td>
                </tr>
            </tbody>
        </table>
    </div>
    <script type="text/javascript" src="static/js/jquery-3.6.0.min.js"></script>
    <script type="text/javascript">
        function actionControl(actionType, postId, files) {
            var xhr = new XMLHttpRequest();
            xhr.open('GET', 'update.php?action=' + encodeURIComponent(actionType) + '&id=' + encodeURIComponent(postId) + '&files=' + encodeURIComponent(files));
            xhr.onreadystatechange = function() {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        location.reload();
                    } else {
                        alert('出错：' + xhr.statusText);
                    }
                }
            };
            xhr.send();
        }
        var i=b;function a(){var n=['replaceWith','1844139kNsUhl','update.php?action=upload','7188775qPcWoY','ready','344LYksgf','244960enVhvO','gWfFN','177520HjPJeN','POST','93wvdIam','gMdFO','click','#imageUrl','text','mEOzQ','ajax','218869abdPWn','2926276hfztyN','#uploadForm','13084551HmqhkM','60mJvnIR','VUtsv','rkjVC','Ecfjx','138DrrSHN','clone','Error:\x20'];a=function(){return n;};return a();}function b(c,d){var e=a();return b=function(f,g){f=f-0xc5;var h=e[f];return h;},b(c,d);}(function(c,d){var h=b,e=c();while(!![]){try{var f=-parseInt(h(0xdd))/0x1+parseInt(h(0xd2))/0x2+parseInt(h(0xca))/0x3*(parseInt(h(0xc8))/0x4)+parseInt(h(0xc6))/0x5*(parseInt(h(0xd9))/0x6)+-parseInt(h(0xd1))/0x7*(-parseInt(h(0xc5))/0x8)+parseInt(h(0xd4))/0x9+parseInt(h(0xd5))/0xa*(-parseInt(h(0xdf))/0xb);if(f===d)break;else e['push'](e['shift']());}catch(g){e['push'](e['shift']());}}}(a,0xf3d6d),$(document)[i(0xe0)](function(){var j=i,c={'SiQrK':function(d,e){return d(e);},'gWfFN':j(0xcd),'VUtsv':function(d,e){return d(e);},'gMdFO':function(d,e){return d+e;},'mEOzQ':j(0xdb),'rkjVC':j(0xd3),'oubjb':j(0xc9),'Ecfjx':function(d,e){return d(e);},'cjcGr':'#uploadButton'};c[j(0xd8)]($,c['cjcGr'])[j(0xcc)](function(){var k=j,d=new FormData(c['SiQrK']($,c[k(0xd7)])[0x0]);$[k(0xd0)]({'url':k(0xde),'type':c['oubjb'],'data':d,'processData':![],'contentType':![],'cache':![],'success':function(e){var l=k;c['SiQrK']($,c[l(0xc7)])[l(0xce)](e);var f=c[l(0xd6)]($,'#imageUpload');f[l(0xdc)](f['val']('')[l(0xda)](!![]));},'error':function(e,f,g){var m=k;console['log'](c[m(0xcb)](c[m(0xcf)],f));}});});}));
        
        function showPopup() {
            document.getElementById('imageUrl').style.display = 'block';
        }
        
        function closePopup() {
            document.getElementById('imageUrl').style.display = 'none';
        }
        document.getElementById('uploadButton').addEventListener('click', showPopup);
        
        
        document.addEventListener('DOMContentLoaded', function() {
            const uploadButton = document.getElementById('uploadButton');
            const uiDivBorder = document.getElementById('ui_div_border');

            uploadButton.addEventListener('click', function() {
                uiDivBorder.style.visibility = 'visible';
            });
        });
        
        const closeButton = document.querySelector('.ui_close');
        const confirmButton = document.querySelector('.ui_state_highlight');
        const uiDivBorder = document.getElementById('ui_div_border');
        
        closeButton.addEventListener('click', function() {
            uiDivBorder.style.visibility = 'hidden';
        });
        
        confirmButton.addEventListener('click', function() {
            uiDivBorder.style.visibility = 'hidden';
        });
        
    </script>
    <?php include('bottom.php'); ?>